package com.hksj.cockpit.controller;

import com.hksj.base.query.BaseDeviceQuery;
import com.hksj.base.query.BaseSpecialityQuery;
import com.hksj.base.vo.DeviceStatusVO;
import com.hksj.base.vo.PropertyVO;
import com.hksj.cm.dto.ClLargeScreenDTO;
import com.hksj.cm.service.ClLargeScreenService;
import com.hksj.cm.vo.CleanLevelCalendarVO;
import com.hksj.cockpit.service.ComprehensiveCockpitService;
import com.hksj.cockpit.vo.AlarmRecordVO;
import com.hksj.common.core.model.Rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName CockpitController
 * @Description TODO
 * @Author @陈章
 * @Date 2024/8/9 9:58
 * @Version 1.0
 */
@Api(tags = "洁净室-综合大屏")
@RestController
@RequestMapping("/api/cockpit")
public class ComprehensiveCockpitController {
    @Autowired
    private ComprehensiveCockpitService service;
    @Autowired
    private ClLargeScreenService clLargeScreenService;

    @ApiOperation(value = "洁净室驾驶舱-环境概览", response = DeviceStatusVO.class)
    @PostMapping("/selectDevice")
    public Rest<List<PropertyVO>> selectDevice(@RequestBody @Validated BaseSpecialityQuery query) {
        List<PropertyVO> page = service.selectDevice(query);
        return Rest.ok(page);
    }

    @ApiOperation("洁净室驾驶舱-洁净度日历(最近30天)")
    @PostMapping("/queryCleanLevelCalendar")
    public Rest<List<CleanLevelCalendarVO>> queryCleanLevelCalendar(@RequestBody ClLargeScreenDTO dto) {
        return Rest.ok(clLargeScreenService.queryCleanLevelCalendar(dto));
    }

    @ApiOperation(value = "洁净室驾驶舱-设备告警分布")
    @PostMapping("/selectDeviceAlarmCountDistribution")
    public Rest<List<Map<String, Integer>>> selectDeviceAlarmCountDistribution(@RequestBody BaseSpecialityQuery query) {
        List<Map<String, Integer>> list = service.selectDeviceAlarmCountDistribution(query);
        return Rest.ok(list);
    }

    @ApiOperation(value = "洁净室驾驶舱-设备报警记录")
    @PostMapping("/queryAlarmRecord")
    public Rest<List<AlarmRecordVO>> queryAlarmRecord(@RequestBody BaseSpecialityQuery query) {
        List<AlarmRecordVO> list = service.queryAlarmRecord(query);
        return Rest.ok(list);
    }

    @ApiOperation(value = "洁净室驾驶舱-设备概览")
    @PostMapping("/queryDeviceOverview")
    public Rest<Map<String, String>> queryDeviceOverview(@RequestBody BaseSpecialityQuery query) {
        Map<String, String> map = service.queryDeviceOverview(query);
        return Rest.ok(map);
    }

    @ApiOperation(value = "洁净室驾驶舱-设备列表")
    @PostMapping("/queryDeviceList")
    public Rest<List<DeviceStatusVO>> queryDeviceList(@RequestBody BaseSpecialityQuery query) {
        List<DeviceStatusVO> list = service.queryDeviceList(query);
        return Rest.ok(list);
    }
}
